let fs = require("fs");
//写文件
for(let i = 1; i < 101; i++) {
    let fileName = 'files/demo' + i +'.txt';
    let random = Math.round(Math.random()*100).toString();
    fs.writeFileSync(fileName, random);     //写文件，文件名为fileNamem,写入的内容为random
}
let totalStr = '';  
let arr=[];

//读文件
for(let j = 1;j < 101; j++) {
    let fileName = 'files/demo' + j + '.txt';
    let buf = fs.readFileSync(fileName);    //同步读取
    // console.log(buf);       //<Buffer 32 38>
   // console.log(buf.toString());  //随机数字
    totalStr = totalStr + ' '+ buf.toString();   //拼接
   arr.push(buf.toString());   //全部放在数组中
}
console.log(totalStr);  //打印拼接